function add0(m){return m<10?'0'+m:m }
function format(shijianchuo)
{
//shijianchuo是整数，否则要parseInt转换
var time = new Date(shijianchuo);
var y = time.getFullYear();
var m = time.getMonth()+1;
var d = time.getDate();
var h = time.getHours();
var mm = time.getMinutes();
var s = time.getSeconds();
return y+'-'+add0(m)+'-'+add0(d)+' '+add0(h)+':'+add0(mm)+':'+add0(s);
}
$(document).ready(function(){
	
	var soshelpId = getQueryParamValue("soshelpId");
	var rootPath = getRootPath();
	
	
	$.ajax({
		method : 'get',
		url : rootPath+'/wechat/api/maintain/rescues/id?soshelpId='+soshelpId,
		error:function(XMLHttpRequest, ajaxOptions, thrownError){
			alert("连接服务器错误!");
		},
		success : function(resultData){
			
			var wholeHtml = '';
			
			$.each(resultData,function(sosHelpIndex,sosHelpObj){
				
				var sosHelpHtml = '';

				var status = '';
				
				if(sosHelpObj.status==11001101){
					status = '待救援';
					
					sosHelpHtml = sosHelpHtml 	 + '<div class="panel panel-default">'
					  							 +   '<ul class="list-group">'
					  							 +     '<li class="list-group-item">'
					  							 +	     '<p>'
					  							 +		   '请求时间：<span>'+ format(sosHelpObj.createDate) +'</span>'
					  							 +		   '<span style="color:red;float:right">'+ status +'</span>'
					  							 +		 '</p>'
					  							 +		 '<p>'
					  							 +		   '救援时间：<span>'+ sosHelpObj.supportDate +'</span>'
					  							 +		 '</p>'
					  							 +		 '<p>'
					  							 +		   '救援地址：<span>'+ '上海市长宁区定西路' +'</span>'
					  							 +		 '</p>'
					  							 +	  '</li>'
					  							 +   '</ul>'
					  							 + '</div>'
					  							 + '<div class="panel panel-default">'
					  							 +   '<ul class="list-group">'
					  							 +     '<li class="list-group-item">'
					  							 +		 '<p>'
					  							 +		   '救援电话：<span>'+ sosHelpObj.serviceHotline +'</span>'
					  							 +		 '</p>'
					  							 +		 '<p>'
					  							 +		   '店&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;名：<span>'+ sosHelpObj.dealerName +'</span>'
					  							 +		 '</p>'
					  							 +		 '<p>'
					  							 +		   '地&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;址：<span>'+ sosHelpObj.detailAddress +'</span>'
					  							 +		 '</p>'
					  							 +	   '</li>'
					  							 +	 '</ul>'
					  							 + '</div>'
						  						 + '<div class="panel panel-default">'
						  						 +   '<input style="background-color:gray" type="button" data-toggle="modal" data-target="#myModal"  value="取消" class="btn btn-default btn-lg btn-block" />'
						  						 + '</div>'
				}
				else if(sosHelpObj.status==11001102){
					status = '救援中';
					
					sosHelpHtml = sosHelpHtml 	 + '<div class="panel panel-default">'
												 +   '<ul class="list-group">'
												 +     '<li class="list-group-item">'
												 +	     '<p>'
												 +		   '请求时间：<span>'+ sosHelpObj.createDate +'</span>'
												 +		   '<span style="color:red;float:right">'+ status +'</span>'
												 +		 '</p>'
												 +		 '<p>'
												 +		   '救援时间：<span>'+ sosHelpObj.supportDate +'</span>'
												 +		 '</p>'
												 +		 '<p>'
												 +		   '救援地址：<span>'+ '上海市长宁区定西路' +'</span>'
												 +		 '</p>'
												 +	  '</li>'
												 +   '</ul>'
												 + '</div>'
												 + '<div class="panel panel-default">'
												 +   '<ul class="list-group">'
												 +     '<li class="list-group-item">'
												 +		 '<p>'
												 +		   '救援电话：<span>'+ sosHelpObj.serviceHotline +'</span>'
												 +		 '</p>'
												 +		 '<p>'
												 +		   '店&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;名：<span>'+ sosHelpObj.dealerName +'</span>'
												 +		 '</p>'
												 +		 '<p>'
												 +		   '地&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;址：<span>'+ sosHelpObj.detailAddress +'</span>'
												 +		 '</p>'
												 +	   '</li>'
												 +	 '</ul>'
												 + '</div>'
				}
				else{
					status = '救援完成';
					
					sosHelpHtml = sosHelpHtml 	 + '<div class="panel panel-default">'
												 +   '<ul class="list-group">'
												 +     '<li class="list-group-item">'
												 +	     '<p>'
												 +		   '请求时间：<span>'+ sosHelpObj.createDate +'</span>'
												 +		   '<span style="color:red;float:right">'+ status +'</span>'
												 +		 '</p>'
												 +		 '<p>'
												 +		   '救援时间：<span>'+ sosHelpObj.supportDate +'</span>'
												 +		 '</p>'
												 +		 '<p>'
												 +		   '救援地址：<span>'+ '上海市长宁区定西路' +'</span>'
												 +		 '</p>'
												 +	  '</li>'
												 +   '</ul>'
												 + '</div>'
												 + '<div class="panel panel-default">'
												 +   '<ul class="list-group">'
												 +     '<li class="list-group-item">'
												 +		 '<p>'
												 +		   '救援电话：<span>'+ sosHelpObj.serviceHotline +'</span>'
												 +		 '</p>'
												 +		 '<p>'
												 +		   '店&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;名：<span>'+ sosHelpObj.dealerName +'</span>'
												 +		 '</p>'
												 +		 '<p>'
												 +		   '地&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;址：<span>'+ sosHelpObj.detailAddress +'</span>'
												 +		 '</p>'
												 +	   '</li>'
												 +	 '</ul>'
												 + '</div>'
				}

				
				wholeHtml += sosHelpHtml;
			});
			
			$("#information").append(wholeHtml);
		}
	});
})
